package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspCodeValue;
import com.hmkj.entity.ErspResPicture;

public class ErspCodeValueDao extends JActiveTable{
	public ErspCodeValueDao() {
		this.setDBTableName("ersp_code_value");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());
		AddField(new JActiveField("code_name_id", "code_name_id", ActiveField.ftString, 11));
		AddField(new JActiveField("code_type", "code_type", ActiveField.ftString, 11));
		AddField(new JActiveField("code_value", "code_value", ActiveField.ftString, 50));
		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));

		setDbKeyFields("id");
	}

	public int add(ErspCodeValue vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("code_name_id", vo.getCode_name_id());
		setFieldValue("code_type", vo.getCode_type());
		setFieldValue("code_value", vo.getCode_value());
		return DBManager.ExecSQL(this.getSQL());
	}

	public String getSQL(ErspCodeValue vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("code_name_id", vo.getCode_name_id());
		setFieldValue("code_type", vo.getCode_type());
		setFieldValue("code_value", vo.getCode_value());
		return this.getSQL();
	}
}
